<?php $this->jQuery()->enable();?>
<div id="page-heading"><h1><?php echo $this->title;?></h1></div>
<?php
echo $this->form ?>
 <script type="text/javascript">
	$(function()
		{
			$("input").blur(function()
					{
						var formElementId = $(this).parent().prev().find('label').attr('for');
						doValidation(formElementId);
					});
		}
	);
	function doValidation(id)
	{
		var url = '/QLHV/public/admin/nguoidung/validateform/';
		var data = {};
		$("input").each(function()
				{
					data[$(this).attr('name')] = $(this).val();
				}
				);
		$.post(url,data,function(resp)
				{
					$("#"+id).parent().find(".errors").remove();
					$("#"+id).parent().find(".error-left").remove();
					$("#"+id).parent().append(getErrorHtml(resp[id], id));
				},'json');
	}
	function getErrorHtml(formErrors, id)
	{
		for(errorKey in formErrors)
		{
			var o = '<td id="'+id+'"><div class="error-left"></div><div class="errors">' + formErrors[errorKey] + '</div></td>';
		}
		return o;
	}
 </script>